#include "mqtt_client_builder.h"

#include "mqtt_client_implement.h"

#include <memory>

MQTTClientBuilder &MQTTClientBuilder::set_server_uri(const std::string &val)
{
    server_uri_ = val;
    return *this;
}

MQTTClientBuilder &MQTTClientBuilder::set_client_id(const std::string &val)
{
    client_id_ = val;
    return *this;
}

MQTTClientBuilder &MQTTClientBuilder::set_client_username(const std::string &val)
{
    client_username_ = val;
    return *this;
}

MQTTClientBuilder &MQTTClientBuilder::set_client_password(const std::string &val)
{
    client_password_ = val;
    return *this;
}

MQTTClientBuilder &MQTTClientBuilder::set_client_ssl_filepath_ca(const std::string &val)
{
    client_ssl_filepath_ca_ = val;
    return *this;
}

MQTTClientBuilder &MQTTClientBuilder::set_client_ssl_filepath_client_cert(const std::string &val)
{
    client_ssl_filepath_client_cert_ = val;
    return *this;
}

MQTTClientBuilder &MQTTClientBuilder::set_client_ssl_filepath_client_key(const std::string &val)
{
    client_ssl_filepath_client_key_ = val;
    return *this;
}

MQTTClientBuilder &MQTTClientBuilder::set_client_ssl_filepath_client_key_password(const std::string &val)
{
    client_ssl_filepath_client_key_password_ = val;
    return *this;
}

MQTTClientBuilder &MQTTClientBuilder::set_connect_timeout_s(const int &val)
{
    connect_timeout_s_ = val;
    return *this;
}

std::shared_ptr<MQTTClientInterface> MQTTClientBuilder::build()
{
    return std::make_shared<MQTTClientImplement>(server_uri_,
                                                 client_id_,
                                                 client_username_,
                                                 client_password_,
                                                 client_ssl_filepath_ca_,
                                                 client_ssl_filepath_client_cert_,
                                                 client_ssl_filepath_client_key_,
                                                 client_ssl_filepath_client_key_password_,
                                                 connect_timeout_s_);
}